﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SnippetBox.Core.Data.Models;
using SnippetBox.Core.Data.Service;

namespace SnippetBox.Web.Areas.Manage.Models {
    public class CategoryModel {
        public CategoryModel(Category category) {
            Category = category;
            CategoryList = new CategoryService().GetCategoryList();

            if (Category != null && Category.ParentCategory != null)
                ParentCategoryId = Category.ParentCategory.CategoryId;
        }

        public CategoryModel() {
            CategoryList = new CategoryService().GetCategoryList();
        }

        public IEnumerable<SelectListItem> CategoryList { get; set; }
        public Category Category { get; set; }

        public int? ParentCategoryId { get; set; }
    }
}